package com.gupao.factory.simple;

import com.gupao.factory.computer.Computer;
import com.gupao.factory.computer.Dell;
import com.gupao.factory.computer.Lenovo;
import com.gupao.factory.computer.MacBook;

/**
 * 简单工厂
 * Created by ktyan on 2017/5/21.
 */
public class SimpleFactory
{
    /**
     * 根据名称获取品牌电脑
     * 
     * @param brandName
     * @return
     */
    public Computer getComputer(String brandName)
    {
        if ("Dell".equals(brandName))
        {
            return new Dell();
        }
        else if ("Lenovo".equals(brandName))
        {
            return new Lenovo();
        }
        else if ("MacBook".equals(brandName))
        {
            return new MacBook();
        }
        else
        {
            System.out.println("未找到该品牌电脑！");
            return null;
        }
        
    }
}
